// console.log('this is mainjs')// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
// 全局依赖
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/index'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import axios from 'axios' // todo 为什么没有改成wsloan的
import echarts from 'echarts'
import 'echarts/chart/line'
import 'echarts/chart/pie'
import 'echarts/component/title'
import 'echarts/component/grid'
import 'echarts/component/tooltip'
import 'echarts/component/legend'
import 'echarts/component/axis'

// websocket
import './config/myws'
import './config/websocket'

// 聊天室
import './js/jquery-1.8.3.min'
import './styles/images/style.scss'
import './styles/chat.scss'
import './styles/drag.scss'

const url="http://report.wsloan.com:8888/css/"
// const url="http://36.7.138.114:5026/css/"
// const url="http://192.168.0.140:8080/css/"
// const url="http://192.168.22.36:8080/css/"

console.log('15:15 1130 service')
window.path = url
let get = (_this,{api,data,isLoading=true},baseUrl) => {
  let innerUrl = url
  if(baseUrl !== undefined){
    innerUrl = baseUrl
  }
  if (isLoading) {
    _this.$vux.loading.show({
      text: 'Loading'
     })
  }
  return _this.$ajax({
    url:innerUrl+api,
    data,
    error: () => {
      this.$warn('系统 '+ api +' 错误')
    },
    success: ()=>{
      if (isLoading) _this.$vux.loading.hide();
    }
  })
}
let post = (_this,{api,data,isLoading=true},baseUrl) => {
  let innerUrl = url
  if(baseUrl !== undefined){
    innerUrl = baseUrl
  }
  if (isLoading) {
    _this.$vux.loading.show({
      text: 'Loading'
     })
  }
  return _this.$ajax({
    url:innerUrl+api,
    data,
    error: () => {
      this.$warn('系统 '+ api +' 错误')
    },
    methods: 'post',
    success: ()=>{
      if (isLoading) _this.$vux.loading.hide();
    }
  })
}

Vue.prototype.$get = get
Vue.prototype.$post = post
Vue.prototype.$echarts = echarts


import {AlertPlugin, ConfirmPlugin, ToastPlugin,LoadingPlugin } from 'vux'

import WSLOAN from '@wsloan/wsloan/src/entries/app.js'

// import {
//   API,`
//   NS
// } from 'fac/constant'

Vue.config.productionTip = false
Vue.prototype.$http = axios
// Vue.prototype.api = API
// Vue.prototype.NS = NS
Vue.use(ElementUI)
Vue.use(LoadingPlugin)
Vue.use(WSLOAN, {
  AlertPlugin, ConfirmPlugin, ToastPlugin
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {
    App
  }
})
